#include<bits/stdc++.h>

using namespace std;
using ll = long long;
#define endl '\n'

struct BTree {
    char val;
    BTree *left, *right;

    BTree(char val, BTree *left = nullptr, BTree *right = nullptr) : val(val), left(left), right(right) {

    }

    void pre_visit() {
        cout << val;
        if (left != nullptr) {
            left->pre_visit();
        }
        if (right != nullptr) {
            right->pre_visit();
        }

    }

    void mid_visit() {
        if (left != nullptr) {
            left->mid_visit();
        }
        cout << val;

        if (right != nullptr) {
            right->mid_visit();
        }
    }

    void post_visit() {
        if (left != nullptr) {
            left->post_visit();
        }


        if (right != nullptr) {
            right->post_visit();
        }
        cout << val;
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    BTree a('A'), b('B'), c('C');
    a.left = &b;
    a.right = &c;
    a.pre_visit();
    return 0;
}
